# coding: utf-8
import tornado.ioloop
import tornado.web
import tornado.httpserver
import tornado.ioloop
import tornado.netutil
import tornado.process
from tornado.httpserver import HTTPServer
from Handlers.PayloadHandler import PayloadHandler
from Handlers.KeysHandler import KeysHandler
from Handlers.LastGroupHandler import LastGroupHandler3
from Handlers.LastGroupHandler import LastGroupHandler4
from Handlers.LastGroupHandler import LastGroupHandler5
from Handlers.InfluxdbCache import InfluxdbCache
from Handlers.MosaicHandler import MosaicHandler
from Handlers.CounterHandlers import MonthCounter

def make_app():
    return tornado.web.Application([
        (r'/dbapi/client_created', PayloadHandler),
        (r'/dbapi/keys/', KeysHandler),
        # (r'/dbapi/last3_group', LastGroupHandler3),
        (r'/dbapi/last_group', LastGroupHandler3),
        (r'/dbapi/mosaic', MosaicHandler),
        (r'/dbapi/last_group2', LastGroupHandler4),
        (r'/dbapi/cache', InfluxdbCache),
        (r'/dbapi/counter', MonthCounter),
        # (r'/test', testHandler)
    ])


if __name__ == '__main__':
    app = make_app()
    server = HTTPServer(app)
    # 23 test
    # server.bind(8888)
    # 58
    server.listen(8888)
    # server.start(0)
    # Forks multiple sub-processes
    tornado.ioloop.IOLoop.current().start()
    print("aaaaa")
